]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appDisplay: Support the 'categories' key for app folders
authorJasper St. Pierre <jstpierre@mecheye.net>
Tue, 28 Jan 2014 17:06:11 +0000 (12:06 -0500)
committerJasper St. Pierre <jstpierre@mecheye.net>
Wed, 29 Jan 2014 19:02:27 +0000 (14:02 -0500)
https://bugzilla.gnome.org/show_bug.cgi?id=723179

js/ui/appDisplay.js

index 165fa59f29241f23b0f4017ffe99838729b2bb59..ec71ad00a6b971a766030422bbe84a94dc9bc69b 100644 (file)
@@ -61,6 +61,13 @@ function _isTerminal(app) {
     return categories.indexOf('TerminalEmulator') > -1;
 }
 
+function _listsIntersect(a, b) {
+    for (let itemA of a)
+        if (b.indexOf(itemA) >= 0)
+            return true;
+    return false;
+}
+
 function _getFolderName(folder) {
     let name = folder.get_string('name');
 
@@ -1069,9 +1076,7 @@ const FolderIcon = new Lang.Class({
         this.view.removeAll();
 
         let appSys = Shell.AppSystem.get_default();
-
-        let folderApps = this._folder.get_strv('apps');
-        folderApps.forEach(Lang.bind(this, function(appId) {
+        let addAppId = (function addAppId(appId) {
             let app = appSys.lookup_app(appId);
             if (!app)
                 return;
@@ -1081,7 +1086,20 @@ const FolderIcon = new Lang.Class({
 
             let icon = new AppIcon(app);
             this.view.addItem(icon);
-        }));
+        }).bind(this);
+
+        let folderApps = this._folder.get_strv('apps');
+        folderApps.forEach(addAppId);
+
+        let folderCategories = this._folder.get_strv('categories');
+        Gio.AppInfo.get_all().forEach(function(appInfo) {
+            let appCategories = _getCategories(appInfo);
+            if (!_listsIntersect(folderCategories, appCategories))
+                return;
+
+            addAppId(appInfo.get_id());
+        });
+
         this.view.loadGrid();
         this.emit('apps-changed');
     },